package demo1;

public class Test2 {
    //找出第一个只出现一次的字母
    public static char findLetter(String str) {
        char[] letters = new char[26];
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            letters[ch - 97]++;
        }
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if (letters[ch - 97] == 1) {
                return ch;
            }
        }
        return '0';
    }
    public static void main(String[] args) {
        String str = "letterrlooq";
        char ch = findLetter(str);
        System.out.println(ch);
    }
}
